#include "sin.h"
#include "ui_sin.h"
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QGridLayout>
#include <QSpacerItem>
#include <QFont>
#include <QPainter>
#include <QMouseEvent>
#include <QDebug>

sin::sin(QWidget *parent) :
QWidget(parent),
ui(new Ui::sin)
{
  ui->setupUi(this);
  mou_f=0;

  this->resize(532,412);
  this->setMinimumSize(532,412);
  this->setMaximumSize(532,412);
  this->setWindowTitle(tr("元素棋"));
  this->setWindowFlag(Qt::FramelessWindowHint);

  QGridLayout *SIGWIN=new QGridLayout(this);
  QWidget *left_up=new QWidget;
  QWidget *low_right=new QWidget;
  SIGWIN->addWidget(left_up,1,1,4,4);
  SIGWIN->addWidget(low_right,7,11,4,1);
  SIGWIN->addWidget(number_label,5,6);
  SIGWIN->addWidget(number_line,5,7,1,5);
  SIGWIN->addWidget(password_label,6,6);
  SIGWIN->addWidget(password_line,6,7,1,5);
  //账号和密码输入的地方
  number_label->setPixmap(QPixmap("../image/登录图标.png"));
  number_label->setMinimumSize(40,40);
  number_label->setMaximumSize(40,40);
  number_line->setMinimumSize(250,40);
  number_line->setMaximumSize(250,40);
  number_line->setFont(QFont(tr("黑体"),28));
  number_label->setWordWrap(true);
  number_label->setScaledContents(true);
  password_label->setPixmap(QPixmap("../image/锁.png"));
  password_label->setMinimumSize(40,40);
  password_label->setMaximumSize(40,40);
  password_line->setMinimumSize(250,40);
  password_line->setMaximumSize(250,40);
  password_line->setFont(QFont(tr("黑体"),28));
  password_label->setWordWrap(true);
  password_label->setScaledContents(true);

  //登录按钮
  SIGWIN->addWidget(sin_button,7,6,2,4);
  sin_button->setFlat(true);
  sin_button->setFixedSize(300,45);
  sin_button->setFont(QFont(tr("黑体"),25));
  sin_button->setStyleSheet("color:white");
  sin_button->setText(tr("登   录"));


  //关闭按钮
  SIGWIN->addWidget(sin_close,1,11,1,1);
  sin_close->setFlat(true);
  sin_close->setFixedSize(45,45);
  sin_close->setFont(QFont(tr("黑体"),25));
  sin_close->setText(tr("×"));
  connect(sin_close,&QPushButton::clicked,[=]{
    this->close();
  });







  this->setLayout(SIGWIN);
}

sin::~sin()
{
  delete ui;
}


void sin::paintEvent(QPaintEvent *)
{
  QPainter *p=new QPainter(this);
  p->drawPixmap(0,0,532,412,QPixmap("../image/背景.png"));
}

void sin::mousePressEvent(QMouseEvent *e)
{
  mou_f=1;
  mouse_x=e->x();
  mouse_y=e->y();
}

void sin::mouseMoveEvent(QMouseEvent *e)
{
  if(mou_f==1)
  {
    int x=this->x()+e->x();
    int y=this->y()+e->y();
    move(x-mouse_x,y-mouse_y);
  }
}

void sin::mouseReleaseEvent(QMouseEvent *e)
{
  mou_f=0;
}











